﻿
Imports System.IO
Imports xmlctrl
Imports xhtmlctrl
Imports webctrl

Public Class passwordpage
    Public Function process(ByRef context As httpContext, ByRef key As String) As Boolean
        Dim buff As MemoryStream = Nothing
        buff = context.buff()
        Dim page As xhtmlpage = Nothing
        page = New xhtmlpage(buff)
        page.title().text = "input password"

        Dim form As form = Nothing
        form = New form(buff)
        form.action = network.thislevelPathMark
        form.method = xhtmlControl_1_1.method_enum.post
        page.body().addchild(form)

        Dim input As input = Nothing
        input = New input(buff)
        input.type = xhtmlctrl.input.type_enum.text
        input.style = "width:100%;font-size:16px;"
        input.name = query.file
        input.value = key
        form.addchild(input)

        input = New input(buff)
        input.type = xhtmlctrl.input.type_enum.password
        input.style = "width:100%;font-size:16px;"
        input.name = query.password
        form.addchild(input)

        input = New input(buff)
        input.type = xhtmlctrl.input.type_enum.submit
        input.style = "width:100%;font-size:16px;"
        input.value = "submit"
        form.addchild(input)

        If page.render() Then
            context.setcontentEncoding(encoding.utf8)
            context.setcontentType(network.http.contentType.texthtmlUtf8)
            context.setstatuscode(Net.HttpStatusCode.OK, "OK")
            Return True
        Else
            raiseError("failed to render xhtmlpage, ignore request.", errorHandle.errorType.warning)
            Return False
        End If
    End Function
End Class
